<?php
/*
 *      ossystoolbar.php
 *      
 *      Copyright 2011 ViRak <vetalrakitin@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

require_once($_SERVER['DOCUMENT_ROOT']."/classes/interface/ostoolbar.php");
require_once($_SERVER['DOCUMENT_ROOT']."/classes/interface/osquestionbox.php");

class ossystoolbar extends ostoolbar {
	
	public $aligment = "auto";
	


	function __construct($parent) {
		parent::__construct($parent);
		$this->width = 1440;
		$this->height = 25;
	}
	
	function style() {
		if ($this->aligment) {
			switch ($this->aligment) {
				case "bottom":{
				}
			}
		}
		$ret = $this->top ? "top:".$this->top."px;":"top:0px;";
		$ret .= $this->left ? "left:".$this->left."px;":"left:0px;";
		$ret .= $this->visible?" visibility:visible;":" visibility:hidden;";
		return "$ret position: absolute;z-index: 65535;width: ".$this->width."px;height: ".$this->height."px;border-style:solid;border-width:3px;border-color:#85C9FF;height: auto;background: #ECF1FE;opacity: 1;display: block;";
	}
	
	function onitemclick($name) {
		switch ($name) {
			case "Setup": {break;}
			case "LogOut": {new osquestionbox($this->uuid,"Завершить сеанс?","logoutanswer");break;}
		}
	}
	
	function logoutanswer($answer) {
		if ($answer == "osqbok") {
			$_SESSION["components"]["CurrentInterface"]->destroy();
			//$_SESSION["components"]["login"]->show();
			new oslogin(0);
		}
	}
	
	function get() {
/*
		$ret = "<input id=".$this->uuid." type='button' value='".$this->caption."'";
		$ret .= $this->active?"":" disabled";
		$ret .= $this->accesskey?" accesskey='".$this->accesskey."'":"";
		$ret .= " onclick=message(this.id,'onclick',0,0)";
		$ret .= ">";
*/
		$ret = "<div id='".$this->uuid."' style='".$this->style()."'";
		$ret .= $this->active?"":" disabled";
		$ret .= $this->visible?"":" hidden";
		$ret .= ">";
		$ret .= "<table style='width: 100%;border: solid black 1px;'><tr>";
		
		$ret .= "<td align = 'center' style='width: 140px;border: solid black 1px;'>";
		$ret .= "<input type='button' value='Setup'";
		$ret .= " onclick=message('".$this->uuid."','onitemclick','Setup',0)";
		$ret .= ">";
		$ret .= "<input type='button' value='Log out'";
		$ret .= " onclick=message('".$this->uuid."','onitemclick','LogOut',0)";
		$ret .= ">";
		$ret .= "</td>";
		
		$ret .= "<td style='border: solid black 1px;'>";
		foreach ($this->items as $name=>$item) {
			$ret .= "<input type='button' value='".htmlspecialchars($item["value"],ENT_QUOTES)."'";
			$ret .= " onclick=message('".$this->uuid."','onitemclick','".$name."',0)";
			$ret .= ">";
		}
		
		$ret .= "</td>";
		$ret .= "<td align = 'center' style='width:80px;border: solid black 1px;'>";
		$ret .= "Time";
		$ret .= "</td>";
		$ret .= "</tr></table>";
		$ret .= "</div>";
		return $ret;
	}
}
?>
